/*Copyright (C) 2013-2020 LZE*/
#include<bits/stdc++.h>
#define INF 0x7f7f7f7f
using namespace std;
typedef long long ll;
ll n,phi[100000];
inline int rd() {
	int x=0;bool ntv=false;char c=getchar();
	while((c<'0'||c>'9')&&c!='-')c=getchar();if(c=='-')ntv=true;else x=(c^48);c=getchar();
	while(c>='0'&&c<='9') {x=x*10+(c^48);c=getchar();}return ntv?-x:x;
}
ll ol_phi_fun(int x) {
	if(phi[x]!=0)return phi[x];
	if(x==1)return 1;
	int l=x;double s=x;
	bool flag=true;
	for(int i=2;i*i<=x;i++) {
		if(x%i==0){
			flag=false;
			s=s-s/double(i);
			while(x%i==0)x/=i;
		}
	}
	if(x>1) s=s-s/double(x);
	ll ret=round(s);
	phi[l]=ret;
	return ret;
}
int main() {
	cin>>n;
	cout<<ol_phi_fun(n);
	return 0;
}

